package com.atguigu.study.base.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author 快点干早点散
 * @Create 2025/4/24 19:24
 * Description:
 */
public class CASHello {
    public static void main(String[] args) {
        AtomicInteger atomicInteger=new AtomicInteger(3);
        System.out.println(atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(3,2022)+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(2022,5));
        atomicInteger.addAndGet(5);
        atomicInteger.compareAndExchange(10,2);
        System.out.println(atomicInteger.compareAndSet(2022,2024)+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.incrementAndGet());//++i
        System.out.println(atomicInteger.getAndIncrement()+"\t"+atomicInteger.get());//i++
    }
}
